<%@ page import="java.util.Objects" %>
<%@ page contentType="text/html;charset=UTF-8" %>

<html>
<head>
    <title>just show results</title>
</head>
<style>
    #result {
        color: deepskyblue;
        text-align: center;
        font-size: 30px;
    }
</style>

<body>
<div id="result">
    <%
        double result = 0;
        String operator = request.getParameter("operator");
        String num1 = request.getParameter("num_1");
        String num2 = request.getParameter("num_2");
        if (num2.equals("0") && operator.equals("/")) {
            out.println("除数不能为0！");
        } else {
            double num_1 = Double.parseDouble(num1);
            double num_2 = Double.parseDouble(num2);
            switch (operator) {
                case "+":
                    result = num_1 + num_2;
                    break;
                case "-":
                    result = num_1 - num_2;
                    break;
                case "*":
                    result = num_1 * num_2;
                    break;
                case "/":
                    result = num_1 / num_2;
                    break;
            }
            out.println("计算结果为：" + result);
        }
    %>
</div>
<div id="back">
    <a href="computer.jsp">
        <button>返回</button>
    </a>
</div>
<%
    application.setAttribute("number", "1");
%>
</body>
</html>